package leetCode;

public class t367 {
    public static void main(String[] args) {

        System.out.println(new Solution().isPerfectSquare(16));
    }

}
class Solution {
    public boolean isPerfectSquare(int num) {
        long left=0;
        long right=num;
        long mid=num;
        while (left<=right){
            mid=(left+right)/2;
            if (mid*mid==num){
                return true;
            }else if (mid*mid<num){
                left=mid+1;
            }else {
                right=mid-1;
            }
        }
        return false;
    }
}